﻿<!DOCTYPE html>
<html>
<head>
	<meta charset="utf-8">
	<meta name="viewport" content="width=device-width,user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
	<link rel="icon" type="image/x-icon" href="img/logo-icon.png">
	<title>AVCare统一消息平台</title>
	<link rel="stylesheet" href="/layui-v2.6.8/css/layui.css" media="all">
	<script src="js/login.js" type="text/javascript"></script>
	<style>
		body {
			font-family: "Microsoft YaHei", "\5FAE\8F6F\96C5\9ED1";
		}

		/*.copyright-box {
			color: #777777;
			z-index: 99;
			position: fixed;
			bottom: 0px;
			width: 100%;
			text-align: center;
		}*/

		.layui-form-label {
			width: 140px !important;
		}

		.layui-input {
			width: 80% !important;
		}

		.layui-form-select dl {
			width: 80% !important;
			min-width: 80% !important;
			left: 60px;
		}

		.layui-form-select .layui-edge {
			right: 38px;
		}

		#messageTemplateEditForm .layui-form-select .layui-edge {
			right: 115px;
		}

		#messageSelectTemplateEditForm .layui-form-select .layui-edge {
			right: 80px;
		}

		#messageEditForm .layui-form-select .layui-edge {
			right: 80px;
		}

		.layui-laypage input {
			width: 40px !important;
		}

		.layui-header {
			background-image: url('img/headerbg.c2af2e3.png');
		}

		.system-logo {
			display: block;
			max-width: 300px;
			max-height: 50px;
		}

		.system-name {
			margin-left: 10px;
			font-weight: 700;
			font-style: normal;
			font-size: 20px;
			color: #fff;
		}

		.header-left-cont {
			display: flex;
			margin-left: 20px;
			align-items: center;
		}

		.layui-nav-tree .layui-nav-child dd.layui-this, .layui-nav-tree .layui-nav-child dd.layui-this a, .layui-nav-tree .layui-this, .layui-nav-tree .layui-this > a, .layui-nav-tree .layui-this > a:hover {
			background-color: #0099ff;
		}

		.layui-btn, .layui-laypage .layui-laypage-curr .layui-laypage-em {
			background-color: #0099ff;
		}

		.successcolor {
			color: #00ce10;
		}

		.failcolor {
			color: #fc3636;
		}

		.infocolor {
			color: #0099ff;
		}

		.layui-layout-admin .layui-header {
			height: 70px;
		}

		.layui-header .header-left-cont {
			padding: 15px 0
		}

		.layui-layout-admin .layui-side {
			top: 70px;
		}

		.layui-table {
			margin: 0;
		}

		.layui-table-view {
			padding: 10px 0;
			box-sizing: border-box;
		}

		.layui-form-checked[lay-skin=primary] i {
			border-color: #0099ff !important;
			background-color: #0099ff;
			color: #fff;
		}

		.layui-layedit {
			margin-left: 60px;
			width: 80%;
		}

		#search_clientInfo_source {
			width: 140px;
			height: 38px;
			border-color: #c4c4c4;
			color: #666;
		}

		.font_size16 {
			font-size: 15px;
			font-family: "Microsoft YaHei", "\5FAE\8F6F\96C5\9ED1";
			font-style: normal;
		}

		.layui-btn-disabled, .layui-btn-disabled:hover, .layui-disabled, .layui-disabled:hover {
			color: #666 !important;
		}
	</style>
</head>
<body>
	<div class="layui-layout layui-layout-admin">
		<div class="layui-header">
			<div data-v-bffb8076="" class="header-left-cont" style="display:flex;">
				<img data-v-bffb8076="" src="/img/logo1.png" alt="图片加载中..." class="system-logo">
				<span data-v-bffb8076="" class="system-name">AVCare统一消息平台</span>
			</div>
			<ul class="layui-nav layui-layout-right">
				<li class="layui-nav-item layui-hide layui-show-md-inline-block">
					<a href="javascript:;">
						<img src="/img/logo-icon.png" class="layui-nav-img">
						<span id="user_name_span"></span>
					</a>
					<dl class="layui-nav-child">
						<dd><a href="#"  onclick="loginout()">退出系统</a></dd>
					</dl>
				</li>
			</ul>
		</div>

		<div class="layui-side layui-bg-black" style="background-color: #2e3d50!important;">
			<div class="layui-side-scroll">
				<!-- 左侧导航区域（可配合layui已有的垂直导航） -->
				<ul class="layui-nav layui-nav-tree" lay-filter="test" style="background-color: #2e3d50 !important;">
					<li class="layui-nav-item layui-nav-itemed">
						<a class="font_size16" href="javascript:;" >管理</a>
						<dl class="layui-nav-child">
							<dd class="layui-this">
								<a id="a_messageManage" href="javascript:;" class="font_size16">消息记录</a>
							</dd>
							<dd>
								<a id="a_clientinfo" href="javascript:;" class="font_size16">消息网关管理</a>
							</dd>
							<dd>
								<a id="a_source" href="javascript:;" class="font_size16">应用管理</a>
							</dd>
							<dd>
								<a id="a_messageType" href="javascript:;" class="font_size16">消息类型管理</a>
							</dd>
							<dd>
								<a id="a_messageTemplateType" href="javascript:;" class="font_size16">消息模板管理</a>
							</dd>
							<dd>
								<a id="a_setting" href="javascript:;" class="font_size16">设置</a>
							</dd>
						</dl>
					</li>
				</ul>
			</div>
		</div>

		<div class="layui-body">
			<!-- 内容主体区域 -->
			<table class="layui-table" style="display:none;" id="clientinfoTable" lay-filter="clientinfoTableFilter"></table>
			<table class="layui-hide" style="display:none;" id="sourceTable" lay-filter="sourceTableFilter"></table>
			<table class="layui-hide" style="display:none;" id="messageTypesTable" lay-filter="messageTypesTableFilter"></table>
			<table class="layui-hide" style="display:none;" id="messageTemplateTable" lay-filter="messageTemplateTableFilter"></table>
			<!--设置页面-->
			<div id="settingpage" style="display: none; margin: 20px;">
				<h3>设置</h3>
				<h4 style="margin: 20px 20px 20px 40px;">自动重发设置</h4>
				<form class="layui-form" method="post" action="/api/SystemInfo/AddOrUpdate" lay-filter="systemInfoEditForm" id="systemInfoEditForm">
					<div class="layui-form-item" style="margin-top: 20px;display:none;">
						<label class="layui-form-label"></label>
						<div class="layui-input-block">
							<input type="text" name="id" lay-verify="id" class="layui-input">
						</div>
					</div>
					<div class="layui-form-item" style="margin-left: 50px;">
						<label><label style="color:red">*</label>重发次数<label style="color:darkgray;">（消息发送失败自动重发，默认3次）</label></label>
						<div class="layui-input-block" style="margin-left:0px;">
							<input type="text" id="retryCount" name="retryCount" lay-verify="number" autocomplete="off" placeholder="请输入重发次数" class="layui-input" value="3" style="width:10%!important;display:inline-block;" required>次
						</div>
					</div>
					<div class="layui-form-item" style="margin-left: 50px;">
						<label><label style="color:red">*</label>初次重发时间间隔<label style="color:darkgray;">（默认10秒）</label></label>
						<div class="layui-input-block" style="margin-left:0px;">
							<input type="text" id="firstRetryIntervalTime" name="firstRetryIntervalTime" lay-verify="number" autocomplete="off" placeholder="请输入初次重发时间间隔" class="layui-input" value="10" style="width: 10% !important; display: inline-block;" required>秒
						</div>
					</div>
					<div class="layui-form-item" style="margin-left: 50px;">
						<label><label style="color:red">*</label>重发时间间隔增长<label style="color:darkgray;">（自动重发次数越多，重发时间间隔越长，默认2倍增长，最多间隔到60秒）</label></label>
						<div class="layui-input-block" style="margin-left:0px;">
							<input type="text" id="retryTimeGrowth" name="retryTimeGrowth" lay-verify="number" autocomplete="off" placeholder="请输入重发时间间隔增长" class="layui-input" value="2" style="width: 10% !important; display: inline-block;" required>倍
						</div>
					</div>
					<div class="layui-form-item" pane="">
						<h4 style="margin: 20px 20px 20px 40px;"><label style="color:red">*</label>发送方式设置</h4>
						<div class="layui-input-block" style="margin-left: 54px;" id="sendtypes">
						</div>
					</div>
					<div class="layui-form-item" pane="">
						<h4 style="margin: 20px 20px 20px 40px;"><label style="color:red">*</label>消息类别设置</h4>
						<div class="layui-input-block" style="margin-left: 54px;" id="msgtypes">
						</div>
					</div>
					<div class="layui-form-item" id="settingFormBtn_div">
						<div class="layui-input-block" style="margin-left: 0px; text-align: center;">
							<button type="submit" class="layui-btn" lay-submit="" lay-filter="settingSubmit">立即提交</button>
							<!--<button type="reset" class="layui-btn">重置</button>-->
						</div>
					</div>
				</form>
			</div>
			<div>
				<div id="searchDiv" style="height:90px;line-height:110px;margin-left:20px;">
					<!--<form class="layui-form">-->
					<span>消息来源：</span>
					<div class="layui-inline">
						<select name="search_clientInfo_source" id="search_clientInfo_source" lay-verify="required" lay-search="">
							<option value="">全部</option>
						</select>
					</div>
					<div class="layui-inline" style="width: 300px;">
						<input type="text" id="search_msg_content" name="search_msg_content" autocomplete="off" placeholder="模糊搜索消息内容" class="layui-input" style="width:100% !important;display:inline-block;">
					</div>
					<button class="layui-btn layui-btn-sm" id="search_btn">搜索</button>
					<!--</form>-->
				</div>
				<table class="layui-hide" id="messageManageTable" lay-filter="messageManageTableFilter"></table>
			</div>
		</div>
	</div>
	<script type="text/html" id="clientToolbar">
		<div class="layui-btn-container">
			<button class="layui-btn layui-btn-sm" lay-event="add">+ 新增</button>
			<!--<button class="layui-btn layui-btn-sm" lay-event="batchDel">批量删除</button>-->
		</div>
	</script>
	<script type="text/html" id="messageToolbar">
		<div class="layui-btn-container">
			<button class="layui-btn layui-btn-sm" lay-event="add">+ 新增</button>
			<!--<button class="layui-btn layui-btn-sm" lay-event="batchDel">批量删除</button>-->
			<!--<a class="layui-btn layui-btn-sm" lay-event="openRabbitmq" target="_blank" href="http://127.0.0.1:15672">RabbitMQ</a>-->
		</div>
	</script>
	<script type="text/html" id="sourceToolbar">
		<div class="layui-btn-container">
			<button class="layui-btn layui-btn-sm" lay-event="add">+ 新增</button>
			<!--<button class="layui-btn layui-btn-sm" lay-event="batchDel">批量删除</button>-->
		</div>
	</script>
	<script type="text/html" id="messageTypeToolbar">
		<div class="layui-btn-container">
			<button class="layui-btn layui-btn-sm" lay-event="add">+ 新增</button>
			<!--<button class="layui-btn layui-btn-sm" lay-event="batchDel">批量删除</button>-->
		</div>
	</script>
	<script type="text/html" id="messageTemplateToolbar">
		<div class="layui-btn-container">
			<button class="layui-btn layui-btn-sm" lay-event="add">+ 新增</button>
			<!--<button class="layui-btn layui-btn-sm" lay-event="batchDel">批量删除</button>-->
		</div>
	</script>
	<script type="text/html" id="bar">
		<a class="layui-btn layui-btn-normal layui-btn-xs" lay-event="detail">查看</a>
		<a class="layui-btn layui-btn-xs" lay-event="edit">编辑</a>
		<!--<a class="layui-btn layui-btn-danger layui-btn-xs" lay-event="del">删除</a>-->
	</script>
	<script type="text/html" id="messagebar">
		<a class="layui-btn layui-btn-normal layui-btn-xs" lay-event="detail">查看</a>
		{{#  if(d.status != 2){ }}
		<a class="layui-btn layui-btn-xs" lay-event="edit">重新发送</a>
		{{#  } }}
		<!--<a class="layui-btn layui-btn-danger layui-btn-xs" lay-event="del">删除</a>-->
	</script>
	<script type="text/html" id="sourcebar">
		<a class="layui-btn layui-btn-normal layui-btn-xs" lay-event="detail">查看</a>
		<a class="layui-btn layui-btn-xs" lay-event="edit">编辑</a>
		{{#  if(d.isCanDelete == 1){ }}
		<a class="layui-btn layui-btn-danger layui-btn-xs" lay-event="del">删除</a>
		{{#  } }}
	</script>
	<script type="text/html" id="messageTypebar">
		<a class="layui-btn layui-btn-normal layui-btn-xs" lay-event="detail">查看</a>
		<a class="layui-btn layui-btn-xs" lay-event="edit">编辑</a>
		<a class="layui-btn layui-btn-xs" lay-event="template">模板</a>
		{{#  if(d.isCanDelete == 1){ }}
		<a class="layui-btn layui-btn-danger layui-btn-xs" lay-event="del">删除</a>
		{{#  } }}
	</script>
	<script type="text/html" id="messageTemplatebar">
		<a class="layui-btn layui-btn-normal layui-btn-xs" lay-event="detail">查看</a>
		<a class="layui-btn layui-btn-xs" lay-event="edit">编辑</a>
		{{#  if(d.isCanDelete == 1){ }}
		<a class="layui-btn layui-btn-danger layui-btn-xs" lay-event="del">删除</a>
		{{#  } }}
	</script>
	<!--添加/修改消息网关的弹出层-->
	<div id="addorupdateclientInfopage" style="display: none">
		<form class="layui-form" method="post" action="/api/ClientInfo/AddOrUpdate" lay-filter="clientInfoEditForm" id="clientInfoEditForm">
			<div class="layui-form-item" style="margin-top: 20px;display:none;">
				<label class="layui-form-label"></label>
				<div class="layui-input-block">
					<input type="text" name="id" lay-verify="id" class="layui-input">
				</div>
			</div>
			<div class="layui-form-item" style="margin-top: 20px;">
				<label class="layui-form-label"><label style="color:red">*</label>应用</label>
				<div class="layui-input-block">
					<select id="clientInfo_source" name="source" lay-verify="required" lay-search="">
						<option value="">直接选择或搜索选择</option>
					</select>
				</div>
			</div>
			<div class="layui-form-item">
				<label class="layui-form-label"><label style="color:red">*</label>网关类型</label>
				<div class="layui-input-block">
					<select id="clientInfo_sendTypes" name="clientType" lay-verify="required" lay-search="" lay-filter="clientInfo_clientType">
						<option value="">直接选择或搜索选择</option>
						<!--<option value="1">微信</option>
						<option value="2">钉钉</option>
						<option value="3">企业微信</option>-->
					</select>
				</div>
			</div>
			<div class="layui-form-item" id="clientInfo_appId">
				<label class="layui-form-label">AppId</label>
				<div class="layui-input-block">
					<input type="text" id="appId" name="appId" lay-verify="title|maxlength100" autocomplete="off" placeholder="请输入AppId" class="layui-input">
				</div>
			</div>
			<div class="layui-form-item">
				<label class="layui-form-label">AppSecret</label>
				<div class="layui-input-block">
					<input type="text" id="appSecret" name="appSecret" lay-verify="title|maxlength100" autocomplete="off" placeholder="请输入AppSecret" class="layui-input">
				</div>
			</div>
			<div class="layui-form-item" id="clientInfo_agendId">
				<label class="layui-form-label">AgendId</label>
				<div class="layui-input-block">
					<input type="text" id="agendId" name="agendId" lay-verify="title|maxlength100" autocomplete="off" placeholder="请输入AgendId" class="layui-input">
				</div>
			</div>
			<div class="layui-form-item" id="clientInfo_clientHost">
				<label class="layui-form-label">移动端地址</label>
				<div class="layui-input-block">
					<input type="text" id="clientHost" name="clientHost" lay-verify="title|maxlength100" autocomplete="off" placeholder="请输入移动端地址" class="layui-input">
				</div>
			</div>
			<div class="layui-form-item" id="clientInfo_corpId">
				<label class="layui-form-label">CorpId</label>
				<div class="layui-input-block">
					<input type="text" id="corpId" name="corpId" lay-verify="title|maxlength100" autocomplete="off" placeholder="请输入CorpId" class="layui-input">
				</div>
			</div>
			<div class="layui-form-item" id="clientInfo_token">
				<label class="layui-form-label">Token</label>
				<div class="layui-input-block">
					<input type="text" id="token" name="token" lay-verify="title|maxlength100" autocomplete="off" placeholder="请输入Token" class="layui-input">
				</div>
			</div>
			<div class="layui-form-item" id="clientInfo_aesKey">
				<label class="layui-form-label">EncodingAESKey</label>
				<div class="layui-input-block">
					<input type="text" id="aesKey" name="aesKey" lay-verify="title|maxlength100" autocomplete="off" placeholder="请输入EncodingAESKey" class="layui-input">
				</div>
			</div>
			<div class="layui-form-item" id="clientInfoFormBtn_div">
				<div class="layui-input-block" style="margin-left: 0px; text-align: center;">
					<button type="submit" class="layui-btn" lay-submit="" lay-filter="clientInfoSubmit">立即提交</button>
					<!--<button type="reset" class="layui-btn">重置</button>-->
				</div>
			</div>
		</form>
	</div>
	<!--添加/修改消息的弹出层-->
	<div id="addorupdatemessagepage" style="display: none">
		<form class="layui-form" method="post" action="/api/Message/AddOrUpdate" lay-filter="messageEditForm" id="messageEditForm">
			<div class="layui-form-item" style="margin-top: 20px;display:none;">
				<label class="layui-form-label"></label>
				<div class="layui-input-block">
					<input type="text" name="id" lay-verify="id" class="layui-input">
				</div>
			</div>
			<div class="layui-form-item" style="margin-top: 20px;">
				<label class="layui-form-label"><label style="color:red">*</label>应用</label>
				<div class="layui-input-block">
					<select id="message_source" name="source" lay-verify="required" lay-search="" lay-filter="message_source-select-filter">
						<option value="">直接选择或搜索选择</option>
					</select>
				</div>
			</div>
			<div class="layui-form-item">
				<label class="layui-form-label"><label style="color:red">*</label>消息类型</label>
				<div class="layui-input-block">
					<select id="msgtype" name="msgtype" lay-verify="required" lay-search="" lay-filter="msgtype-select-filter">
						<option value="">直接选择或搜索选择</option>
					</select>
				</div>
			</div>
			<div class="layui-form-item layui-form-text">
				<label class="layui-form-label"><label style="color:red">*</label>消息内容</label>
				<div class="layui-input-block">
					<textarea placeholder="请输入消息内容" id="messagepage_content" name="content" lay-verify="required" class="layui-textarea" rows="19" style="width: 90% !important;"></textarea>
				</div>
			</div>
			<!--<div class="layui-form-item">
				<label class="layui-form-label">延迟时间(毫秒)</label>
				<div class="layui-input-block">
					<input type="text" name="delayTime" lay-verify="title" autocomplete="off" placeholder="请输入延迟时间" class="layui-input" value="0">
				</div>
			</div>-->
			<div class="layui-form-item" id="messageFormBtn_div">
				<div class="layui-input-block" style="margin-left: 0px; text-align: center;">
					<button type="submit" class="layui-btn" lay-submit="" lay-filter="messageSubmit">立即提交</button>
					<!--<button type="reset" class="layui-btn">重置</button>-->
				</div>
			</div>
		</form>
	</div>
	<!--添加/修改应用的弹出层-->
	<div id="addorupdatesourcepage" style="display: none">
		<form class="layui-form" method="post" action="/api/Source/AddOrUpdate" lay-filter="sourceEditForm" id="sourceEditForm">
			<div class="layui-form-item" style="margin-top: 20px;display:none;">
				<label class="layui-form-label"></label>
				<div class="layui-input-block">
					<input type="text" name="id" lay-verify="id" class="layui-input">
				</div>
			</div>
			<div class="layui-form-item" style="margin-top: 20px;">
				<label class="layui-form-label"><label style="color:red">*</label>应用code</label>
				<div class="layui-input-block">
					<input type="text" id="code" name="code" lay-verify="required|maxlength100" autocomplete="off" placeholder="请输入应用code" class="layui-input" />
				</div>
			</div>
			<div class="layui-form-item">
				<label class="layui-form-label"><label style="color:red">*</label>名称</label>
				<div class="layui-input-block">
					<input type="text" id="name" name="name" lay-verify="required|maxlength100" autocomplete="off" placeholder="请输入应用名称" class="layui-input" />
				</div>
			</div>
			<div class="layui-form-item" id="sourceFormBtn_div">
				<div class="layui-input-block" style="margin-left: 0px; text-align: center;">
					<button type="submit" class="layui-btn" lay-submit="" lay-filter="sourceSubmit">立即提交</button>
					<!--<button type="reset" class="layui-btn">重置</button>-->
				</div>
			</div>
		</form>
	</div>
	<!--添加/修改消息类型的弹出层-->
	<div id="addorupdatemessagetypespage" style="display: none">
		<form class="layui-form" method="post" action="/api/MessageTypes/AddOrUpdate" lay-filter="messageTypesEditForm" id="messageTypesEditForm">
			<div class="layui-form-item" style="margin-top: 20px;display:none;">
				<label class="layui-form-label"></label>
				<div class="layui-input-block">
					<input type="text" name="id" lay-verify="id" class="layui-input">
				</div>
			</div>
			<div class="layui-form-item" style="margin-top: 20px;">
				<label class="layui-form-label"><label style="color:red">*</label>类型编号</label>
				<div class="layui-input-block">
					<input type="text" id="messageTypes_code" name="code" lay-verify="required|maxlength100" autocomplete="off" placeholder="请输入类型编号" class="layui-input" />
				</div>
			</div>
			<div class="layui-form-item">
				<label class="layui-form-label"><label style="color:red">*</label>类型名称</label>
				<div class="layui-input-block">
					<input type="text" id="messageTypes_name" name="name" lay-verify="required|maxlength100" autocomplete="off" placeholder="请输入类型名称" class="layui-input" />
				</div>
			</div>
			<div class="layui-form-item" style="margin-top: 20px;">
				<label class="layui-form-label"><label style="color:red">*</label>应用</label>
				<div class="layui-input-block">
					<select id="messageTypes_source" name="source" lay-verify="required" lay-search="">
						<option value="">直接选择或搜索选择</option>
					</select>
				</div>
			</div>
			<div class="layui-form-item">
				<label class="layui-form-label"><label style="color:red">*</label>消息类别</label>
				<div class="layui-input-block">
					<select id="messageTypes_msgTypes" name="msgType" lay-verify="required" lay-search="" lay-filter="messageTypes_msgTypes">
						<option value="">直接选择或搜索选择</option>
					</select>
				</div>
			</div>
			<div class="layui-form-item">
				<label class="layui-form-label"><label style="color:red">*</label>网关类型</label>
				<div class="layui-input-block">
					<select id="messageTypes_sendTypes" name="sendType" lay-verify="required" lay-search="" lay-filter="messageTypes_sendTypes">
						<option value="">直接选择或搜索选择</option>
					</select>
				</div>
			</div>
			<!--<div class="layui-form-item">
				<label class="layui-form-label">启用</label>
				<div class="layui-input-block">
					<input type="checkbox" checked="" name="enable" lay-skin="switch" lay-filter="switchTest" lay-text="ON|OFF">
				</div>
			</div>-->
			<div class="layui-form-item" id="messageTypesFormBtn_div">
				<div class="layui-input-block" style="margin-left: 0px; text-align: center;">
					<button type="submit" class="layui-btn" lay-submit="" lay-filter="messageTypesSubmit">立即提交</button>
					<!--<button type="reset" class="layui-btn">重置</button>-->
				</div>
			</div>
		</form>
	</div>
	<!--添加/修改消息模板的弹出层-->
	<div id="addorupdatemessagetemplatepage" style="display: none">
		<form class="layui-form" method="post" action="/api/MessageTmplates/AddOrUpdate" lay-filter="messageTemplateEditForm" id="messageTemplateEditForm">
			<div class="layui-form-item" style="margin-top: 20px;display:none;">
				<label class="layui-form-label"></label>
				<div class="layui-input-block">
					<input type="text" name="id" lay-verify="id" class="layui-input">
				</div>
			</div>
			<div class="layui-form-item" style="margin-top: 20px;">
				<label class="layui-form-label"><label style="color:red">*</label>标题</label>
				<div class="layui-input-block">
					<input type="text" id="messagetemplate_name" name="name" lay-verify="required|maxlength100" autocomplete="off" placeholder="请输入名称" class="layui-input">
				</div>
			</div>
			<div class="layui-form-item">
				<label class="layui-form-label"><label style="color:red">*</label>正文</label>
				<div class="layui-input-block">
					<textarea id="messagetemplate_content" name="content" lay-verify="required|maxlength2000" class="layui-textarea" rows="5" style="width: 80% !important;"></textarea>
				</div>
			</div>
			<div class="layui-form-item">
				<label class="layui-form-label"><label style="color:red">*</label>内容示例</label>
				<div class="layui-input-block">
					<textarea id="messagetemplate_example" name="example" lay-verify="required|maxlength2000" class="layui-textarea" rows="5" style="width: 80% !important;"></textarea>
				</div>
			</div>
			<div class="layui-form-item">
				<label class="layui-form-label"><label style="color:red">*</label>发送JSON</label>
				<div class="layui-input-block">
					<textarea id="messagetemplate_sendJson" name="sendJson" lay-verify="required" class="layui-textarea" rows="19" style="width: 90% !important;"></textarea>
				</div>
			</div>
			<!--<div class="layui-form-item">
				<label class="layui-form-label">启用</label>
				<div class="layui-input-block">
					<input type="checkbox" checked="" name="enable" lay-skin="switch" lay-filter="switchTest" lay-text="ON|OFF">
				</div>
			</div>-->
			<div class="layui-form-item">
				<div class="layui-input-block">
					<label style="color:red;">在发送时，需要将内容中的参数（{{xxx}}内为参数）赋值替换为需要的信息</label>
				</div>
			</div>
			<div class="layui-form-item" id="messageTemplateFormBtn_div">
				<div class="layui-input-block" style="margin-left: 0px; text-align: center;">
					<button type="submit" class="layui-btn" lay-submit="" lay-filter="messageTemplateSubmit">保存</button>
					<!--<button type="reset" class="layui-btn">重置</button>-->
				</div>
			</div>
		</form>
	</div>
	<!--消息类型选择模板的弹出层-->
	<div id="addorupdateselecttemplatepage" style="display: none">
		<form class="layui-form" method="post" action="/api/MessageTypes/AddOrUpdateMessageTemplate" lay-filter="messageSelectTemplateEditForm" id="messageSelectTemplateEditForm">
			<div class="layui-form-item" style="margin-top: 20px;display:none;">
				<label class="layui-form-label"></label>
				<div class="layui-input-block">
					<input type="text" name="id" lay-verify="id" class="layui-input">
				</div>
			</div>
			<div class="layui-form-item" style="margin-top: 20px;">
				<label class="layui-form-label">消息模板</label>
				<div class="layui-input-block">
					<select id="messageTemplate" name="messageTemplateId" lay-search="">
						<option value="">直接选择或搜索选择</option>
					</select>
				</div>
			</div>
			<div class="layui-form-item" id="messageSelectFormBtn_div">
				<div class="layui-input-block" style="margin-left: 0px; text-align: center;">
					<button type="submit" class="layui-btn" lay-submit="" lay-filter="messageSelectTemplateSubmit">保存</button>
					<!--<button type="reset"  class="layui-btn" >重置</button>-->
				</div>
			</div>
		</form>
	</div>

	<!--添加/修改消息的弹出层-->
	<!--<div id="test_addorupdatemessagepage" style="display: none">
		<form class="layui-form" method="post" action="/api/Message/AddOrUpdate" lay-filter="test_messageEditForm" id="test_messageEditForm">
			<div class="layui-form-item" style="margin-top:40px;">
				<label class="layui-form-label"><label style="color:red">*</label>消息内容</label>
				<div class="layui-input-block">
					<textarea placeholder="请输入消息内容" id="test_messagepage_content" name="content" lay-verify="required" class="layui-textarea" rows="8" style="width: 80% !important;min-height:700px;"></textarea>
				</div>
			</div>
			<div class="layui-form-item" id="test_messageFormBtn_div">
				<div class="layui-input-block" style="margin-left: 0px; text-align: center;">
					<button type="submit" class="layui-btn" lay-submit="" lay-filter="test_messageSubmit">立即提交</button>
					<button type="reset" class="layui-btn">重置</button>
				</div>
			</div>
		</form>
	</div>-->
	<script src="/layui-v2.6.8/layui.js"></script>
	<script>
		var clientInfoTable;
		function renderClientinfoTable() {
			clientInfoTable = layui.table;
			var loadix = layer.load(1, { shade: [0.1, '#fff'] });
			//执行一个 table 实例
			clientInfoTable.render({
				elem: '#clientinfoTable'
				, height: 830
				, url: '/api/ClientInfo/GetClientInfoList' //数据接口
				, title: '消息网关'
				, page: true //开启分页
				, toolbar: '#clientToolbar' //开启工具栏，此处显示默认图标，可以自定义模板，详见文档,
                , defaultToolbar: ['filter']
                , totalRow: false //开启合计行
                , autoSort: false
				, limit: 20
				, cellMinWidth: 80
				, cols: [
					[ //表头
						{ field: 'id', title: 'ID', width: 80, sort: true, fixed: 'left' }
						//, { field: 'clientName', title: '名称', width: 100 }
						, { field: 'sourceStr', title: '应用', width: 250 }
						, { field: 'clientTypeStr', title: '网关类型', width: 120, sort: true }
						, { field: 'appId', title: 'AppId', width: 180 }
						, { field: 'appSecret', title: 'AppSecret', width: 200 }
						, { field: 'agendId', title: 'AgendId', width: 200 }
						, { field: 'clientHost', title: '移动端地址', width: 180 }
						, { field: 'corpId', title: 'CorpId', width: 200 }
						, { field: 'token', title: 'Token', width: 200 }
                        , { field: 'aesKey', title: 'EncodingAESKey', width: 200 }
						, { fixed: 'right', title: '操作', width: 180, align: 'center', toolbar: '#bar' }
					]
				]
				//, cols: [
				//	[ //表头
				//		{ type: 'checkbox', fixed: 'left', rowspan: 2 }
				//		, { field: 'id', title: 'ID', width: 80, sort: true, fixed: 'left', rowspan: 2 }
				//		, { field: 'clientName', title: '名称', width: 100, rowspan: 2 }
				//		, { field: 'clientTypeStr', title: '平台类型', width: 120, sort: true, rowspan: 2 }
				//		, { field: 'appId', title: '平台AppId', width: 180, rowspan: 2 }
				//		, { field: 'appSecret', title: '平台AppSecret', width: 200, rowspan: 2 }
				//		, { field: 'clientHost', title: '客户端域名', width: 180, rowspan: 2 }
				//		, { field: 'corpId', title: '企业微信专业企业Id', width: 200, rowspan: 2 }
				//		, { field: 'token', title: '验证Token', width: 100, rowspan: 2 }
				//		, { field: 'aesKey', title: '消息加密密钥', width: 135, rowspan: 2 }
				//		, { field: 'agendId', title: '企业应用的AgendId', width: 200, rowspan: 2 }
				//		, { field: 'firstMenuName', title: '第一菜单名称', width: 135, rowspan: 2 }
				//		, { title: '消息模版', align: 'center', colspan: 5 }
				//		, { fixed: 'right', title: '操作', width: 180, align: 'center', toolbar: '#bar', rowspan: 2 }
				//	],
				//	[

				//		{ field: 'bookingApprove', title: '审批通过提醒', width: 200 }
				//		, { field: 'bookingReject', title: '审批驳回提醒', width: 200 }
				//		, { field: 'auditRemind', title: '审批提醒', width: 200 }
				//                    , { field: 'bookingCancel', title: '取消提醒', width: 200 }
				//                    , { field: 'toSiteManagerRemind', title: '发送给场地管理员', width: 200 }
				//	]
				//]
			});

			layer.close(loadix);
		}

		var messageManageTable;
        function renderMessageManageTable(source,msgcontent) {
			messageManageTable = layui.table;
			$ = layui.$;
			var loadix = layer.load(1, { shade: [0.1, '#fff'] });
			//执行一个 table 实例
			messageManageTable.render({
				elem: '#messageManageTable'
				, url: '/api/Message/GetList?client_source=' + source + '&msg_content=' + msgcontent //数据接口
                , height: 750
				, title: '消息管理'
				, page: true //开启分页
                , toolbar: '#messageToolbar' //开启工具栏，此处显示默认图标，可以自定义模板，详见文档
                , defaultToolbar: ['filter']
                , totalRow: false //开启合计行
                , limit: 15
				, limits: [15, 30, 45, 100]
				, autoSort: false
				, cols: [[ //表头
					{ type: 'checkbox', fixed: 'left' }
					, { field: 'id', title: 'ID', width: 80, sort: true, fixed: 'left' }
					, { field: 'sourceStr', title: '应用', width: 250 }
					, { field: 'msgtypeStr', title: '消息类型', width: 500 }
					, { field: 'content', title: '消息内容', width: 400 }
					, {
						field: 'statusStr', title: '状态', width: 80, sort: true, templet: function (d) {
							if (d.status == "0") {
								return '<span class="successcolor">' + d.statusStr + '</span>'
							}
							if (d.status == "1") {
								return '<span class="successcolor">' + d.statusStr + '</span>'
							}
							if (d.status == "2") {
								return '<span class="successcolor">' + d.statusStr + '</span>'
							}
							if (d.status == "3") {
								return '<span class="failcolor">' + d.statusStr + '</span>'
							}
						}
                    }
                    , { field: 'responseMsg', title: '响应参数', width: 280 }
					, { field: 'createtime', title: '创建时间', width: 200, sort: true }
					//, { field: 'delayTime', title: '延迟时间(毫秒)', width: 130 }
					, { fixed: 'right', title: '操作', width: 220, align: 'center', toolbar: '#messagebar' }
				]],
				success: function (data) {
                },
                error: function (e) {
                    logout(e);
                }
			});

			layer.close(loadix);

		}

		var sourceTable;
		function renderSourceTable() {
			sourceTable = layui.table;
			$ = layui.$;
			var loadix = layer.load(1, { shade: [0.1, '#fff'] });
			//执行一个 table 实例
			sourceTable.render({
				elem: '#sourceTable'
				, height: 830
				, url: '/api/Source/GetList' //数据接口
				, title: '应用管理'
				, page: true //开启分页
                , toolbar: '#sourceToolbar' //开启工具栏，此处显示默认图标，可以自定义模板，详见文档
                , defaultToolbar: ['filter']
				, totalRow: false //开启合计行
                , limit: 20
                , autoSort: false
				, cols: [[ //表头
					{ field: 'id', title: 'ID', width: 80, sort: true, fixed: 'left' }
					, { field: 'code', title: '应用code', width: 250 }
					, { field: 'name', title: '名称', width: 350 }
                    , { field: 'ak', title: '密钥id', width: 320 }
                    , { field: 'sk', title: '密钥', width: 320 }
					, { fixed: 'right', title: '操作', width: 280, align: 'center', toolbar: '#sourcebar' }
				]],
				success: function (data) {
                },
                error: function (e) {
                    //logout(e);
                }
			});

			layer.close(loadix);

		}
		//消息类型table
		var messageTypesTable;
		function renderMessageTypeTable() {
			messageTypesTable = layui.table;
			$ = layui.$;
			var loadix = layer.load(1, { shade: [0.1, '#fff'] });
			//执行一个 table 实例
			messageTypesTable.render({
				elem: '#messageTypesTable'
				, height: 830
				, url: '/api/MessageTypes/GetList' //数据接口
				, title: '消息类型'
				, page: true //开启分页
                , toolbar: '#messageTypeToolbar' //开启工具栏，此处显示默认图标，可以自定义模板，详见文档
                , defaultToolbar: ['filter']
                , totalRow: false //开启合计行
                , autoSort: false
				, limit: 20
				, cols: [[ //表头
					{ field: 'id', title: 'ID', width: 80, sort: true, fixed: 'left' }
					, { field: 'code', title: '编号', width: 250 }
					, { field: 'name', title: '名称', width: 300 }
					, { field: 'sourceStr', title: '应用', width: 350, sort: true }
					, { field: 'msgTypeStr', title: '消息类别', width: 120, sort: true }
                    , { field: 'sendTypeStr', title: '网关类型', width: 150, sort: true }
                    , { field: 'messageTemplateName', title: '关联模板', width: 200}
					, { field: 'createTime', title: '创建时间', width: 200, sort: true }
					//, {
					//	field: 'enableStr', title: '状态', width: 100, templet: function (d) {
					//		if (d.enable == "1") {
					//			return '<span class="successcolor">' + d.enableStr + '</span>'
					//		}
					//		else {
					//			return '<span class="failcolor">' + d.enableStr + '</span>'
					//		}
					//	}
					//}
					, { fixed: 'right', title: '操作', width: 230, align: 'center', toolbar: '#messageTypebar' }
				]],
				success: function (data) {
                },
                error: function (e) {
                    logout(e);
                }
			});

			layer.close(loadix);

		}

		//消息模板table
		var messageTemplateTable;
		function renderMessageTemplateTable() {
			messageTemplateTable = layui.table;
			$ = layui.$;
			var loadix = layer.load(1, { shade: [0.1, '#fff'] });
			//执行一个 table 实例
			messageTemplateTable.render({
				elem: '#messageTemplateTable'
				, height: 830
				, url: '/api/MessageTmplates/GetList' //数据接口
				, title: '消息模板'
				, page: true //开启分页
                , toolbar: '#messageTemplateToolbar' //开启工具栏，此处显示默认图标，可以自定义模板，详见文档
                , defaultToolbar: ['filter']
                , totalRow: false //开启合计行
                , autoSort: false
				, limit: 20
				, cols: [[ //表头
					{ field: 'id', title: 'ID', width: 80, sort: true, fixed: 'left' }
					, { field: 'templateId', title: '模板ID', width: 450 }
					, { field: 'name', title: '标题', width: 400 }
					, { field: 'createTime', title: '创建时间', width: 200, sort: true }
					//, {
					//	field: 'enableStr', title: '状态', width: 100, templet: function (d) {
					//		if (d.enable == "1") {
					//			return '<span class="successcolor">' + d.enableStr + '</span>'
					//		}
					//		else {
					//			return '<span class="failcolor">' + d.enableStr + '</span>'
					//		}
					//	}
					//}
					, { fixed: 'right', title: '操作', width: 430, align: 'center', toolbar: '#messageTemplatebar' }
				]],
				success: function (data) {
                },
                error: function (e) {
                    logout(e);
                }
			});

			layer.close(loadix);

		}

		function clientInfoClientTypeChangeShowHide(value) {
			if (value === "1" || value === 1) {
                $("#clientInfo_corpId").css('display', 'block');
				$("#clientInfo_agendId").css('display', 'none');

				$("#clientInfo_token").css('display', 'block');
				$("#clientInfo_aesKey").css('display', 'block');
                $("#clientInfo_appId").css('display', 'block');
                $("#clientInfo_clientHost").css('display', 'block');
			}
			else if (value === "2" || value === 2) {
				$("#clientInfo_token").css('display', 'none');
				$("#clientInfo_aesKey").css('display', 'none');

				$("#clientInfo_appId").css('display', 'block');
				$("#clientInfo_corpId").css('display', 'block');
                $("#clientInfo_agendId").css('display', 'block');
                $("#clientInfo_clientHost").css('display', 'block');
			}
			else if (value === "3" || value === 3) {
				$("#clientInfo_appId").css('display', 'none');
				$("#clientInfo_token").css('display', 'none');
				$("#clientInfo_aesKey").css('display', 'none');

				$("#clientInfo_corpId").css('display', 'block');
                $("#clientInfo_agendId").css('display', 'block');
                $("#clientInfo_clientHost").css('display', 'block');
            }
            else if (value === "4" || value === 4) {
                $("#clientInfo_appId").css('display', 'block');
                $("#clientInfo_token").css('display', 'none');
                $("#clientInfo_aesKey").css('display', 'none');

                $("#clientInfo_corpId").css('display', 'block');
                $("#clientInfo_agendId").css('display', 'none');
                $("#clientInfo_clientHost").css('display', 'none');
            }
			else {
				clearClientInfoClientTypeChange();
			}
		}
		function clientInfoClientTypeChange() {
			var form = layui.form;
			//监听下拉框值改变事件
			form.on('select(clientInfo_clientType)', function (data) {
				clientInfoClientTypeChangeShowHide(data.value);
			})
		}

		function clearClientInfoClientTypeChange() {
			$("#clientInfo_corpId").css('display', 'block');
			$("#clientInfo_agendId").css('display', 'block');
			$("#clientInfo_token").css('display', 'block');
			$("#clientInfo_aesKey").css('display', 'block');
            $("#clientInfo_appId").css('display', 'block');
            $("#clientInfo_clientHost").css('display', 'block');
		}

		function logout(e)
		{
			if (e.responseJSON != null && e.responseJSON != undefined && e.responseJSON.code == 401)
			{
                window.location.href = "/login.html";
            }
		}
		function isInteger(obj)
		{
			var intobj = parseInt(obj);
            return intobj %1 === 0
		}
		function bindSource() {
			$ = layui.$;
			//动态加载应用下拉框值
			$.ajax({
				url: '/api/Source/GetAll',
				dataType: 'json', //服务器返回json格式数据
				type: 'get', //HTTP请求类型
				success: function (data) {
					$.each(data.data, function (index, value) {
						var ele1 = $("#message_source option[value='" + value.id + "']");
						if (ele1.length == 0) {
							$('#message_source').append(new Option(value.name, value.id));// 下拉菜单里添加元素
						}
						var ele2 = $("#clientInfo_source option[value='" + value.id + "']");
						if (ele2.length == 0) {
							$('#clientInfo_source').append(new Option(value.name, value.id));// 下拉菜单里添加元素
						}
						var ele3 = $("#messageTypes_source option[value='" + value.id + "']");
						if (ele3.length == 0) {
							$('#messageTypes_source').append(new Option(value.name, value.id));// 下拉菜单里添加元素
                        }
                        var ele4 = $("#search_clientInfo_source option[value='" + value.id + "']");
                        if (ele4.length == 0) {
                            $('#search_clientInfo_source').append(new Option(value.name, value.id));// 下拉菜单里添加元素
                        }
						layui.form.render("select");
					});

                },
				error: function (e) {
					logout(e);
                }
			});
		}

		function bidMsgType(sourceId) {
			//动态加载消息类型下拉框值
			$ = layui.$;
			$.ajax({
				url: '/api/MessageTypes/GetAll?sourceId=' + sourceId,
				dataType: 'json', //服务器返回json格式数据
				type: 'get', //HTTP请求类型
				success: function (data) {
					if (data.data.length > 0) {
						$.each(data.data, function (index, value) {
							var ele = $("#msgtype option[value='" + value.id + "']");
							if (ele.length == 0) {
								$('#msgtype').append(new Option(value.name + "（" + value.code + "）", value.id));// 下拉菜单里添加元素
							}
						});

						layui.form.render("select");
					}
                },
                error: function (e) {
                    logout(e);
                }
			});

		}

		function bidMsgTemplate() {
			//动态加载消息类型下拉框值
			//执行清空
			$("#messageTemplate").empty();
			$('#messageTemplate').append(new Option("直接选择或搜索选择", ''));// 下拉菜单里添加元素
			$ = layui.$;
			$.ajax({
				url: '/api/MessageTmplates/GetAll',
				dataType: 'json', //服务器返回json格式数据
				type: 'get', //HTTP请求类型
				success: function (data) {
					if (data.data.length > 0) {
						$.each(data.data, function (index, value) {
							var ele = $("#messageTemplate option[value='" + value.id + "']");
							if (ele.length == 0) {
								$('#messageTemplate').append(new Option(value.name, value.id));// 下拉菜单里添加元素
							}
						});

						layui.form.render("select");
					}
                },
                error: function (e) {
                    logout(e);
                }
			});

		}
		//JS
		layui.use(['element', 'table', 'layer', 'util', 'form', 'layedit'], function () {
			var element = layui.element
				, layer = layui.layer
				, util = layui.util
				, $ = layui.$
				, laypage = layui.laypage //分页
				, laydate = layui.laydate //日期
				, table = layui.table //表格
				, carousel = layui.carousel //轮播
				, upload = layui.upload //上传
				, element = layui.element //元素操作
				, slider = layui.slider //滑块
				, dropdown = layui.dropdown //下拉菜单
				, form = layui.form //表单
			var date = new Date().getFullYear();
			var localstorage = localStorage.getItem("username");
			if (localstorage == null || localstorage == undefined) {
                window.location.href = "/login.html";
            }
			//$("#copyright").text("Copyright©2019~" + date + ".AVCC. All Rights Reserved. 同方艾威康 版权所有");
            $("#user_name_span").text(localStorage.getItem("username"));
            $("#search_btn").click(function () {
                renderMessageManageTable($("#search_clientInfo_source").val(), $("#search_msg_content").val())
            })
			//动态加载消息类型下拉框值
			bidMsgType(0);
			//动态加载应用下拉框值
			bindSource();

            renderMessageManageTable($("#search_clientInfo_source").val(), $("#search_msg_content").val());
			var mainIndex;
			//消息网关配置监听头工具栏事件
			table.on('toolbar(clientinfoTableFilter)', function (obj) {
				var checkStatus = table.checkStatus(obj.config.id)
					, data = checkStatus.data; //获取选中的数据
				switch (obj.event) {
					case 'add':
						//iframe层
						mainIndex = layer.open({
							type: 1,
							offset: 'r',
							anim: 'slideLeft', // 从右往左
							title: '新增',
							shadeClose: true,
							shade: 0.1,
							area: ['30%', '100%'],//宽 高
							content: $("#addorupdateclientInfopage"),
							success: function (index) {
								//清空数据表格
								$('#clientInfoEditForm')[0].reset();
								var readForm = layui.$('[lay-filter="clientInfoEditForm"]')
								readForm.find('input,textarea,select').prop('disabled', false);
                                $("#clientInfoEditForm #appId").removeClass("layui-btn-disabled");
                                $("#clientInfoEditForm #appSecret").removeClass("layui-btn-disabled");
                                $("#clientInfoEditForm #agendId").removeClass("layui-btn-disabled");
                                $("#clientInfoEditForm #clientHost").removeClass("layui-btn-disabled");
                                $("#clientInfoEditForm #corpId").removeClass("layui-btn-disabled");
                                $("#clientInfoEditForm #token").removeClass("layui-btn-disabled");
                                $("#clientInfoEditForm #aesKey").removeClass("layui-btn-disabled");
								$("#clientInfoFormBtn_div").show();
								layui.form.render();
							},
							cancel: function () {
								//清除下拉框值改变
								clearClientInfoClientTypeChange();
							}
						});
						break;
					case 'batchDel':
						if (data.length === 0) {
							layer.msg('请选择一行');
						} else {
							var idArray = [];
							for (var i = 0; i < data.length; i++) {
								idArray.push(data[i].id);
							}
							layer.confirm('确认要删除吗？', function (index) {
								$.ajax({
									url: "/api/ClientInfo/BatchDelete?ids=" + idArray.join(','),
									type: "get",
									success: function (info) {
										if (info.code === 1) {
                                            layer.close(index);
											//刷新数据表格
											clientInfoTable.reload('clientinfoTable')
										} else {
											layer.msg(info.msg);
										}
                                    },
                                    error: function (e) {
                                        logout(e);
                                    }
								});
							});
						}
						break;
				};
			});

			//消息网关配置监听行工具事件
			table.on('tool(clientinfoTableFilter)', function (obj) { //注：tool 是工具条事件名，test 是 table 原始容器的属性 lay-filter="对应的值"
				var data = obj.data //获得当前行数据
					, layEvent = obj.event; //获得 lay-event 对应的值
				if (layEvent === 'detail') {
					//iframe层
					layer.open({
						type: 1,
						offset: 'r',
						anim: 'slideLeft', // 从右往左
						title: '查看',
						shadeClose: true,
						shade: 0.1,
						area: ['30%', '100%'],//宽 高
						content: $("#addorupdateclientInfopage"),
						success: function () {
							form.val('clientInfoEditForm', data);
							var readForm = layui.$('[lay-filter="clientInfoEditForm"]')
                            readForm.find('input,textarea,select').prop('disabled', true);
                            $("#clientInfoEditForm #appId").addClass("layui-btn-disabled");
                            $("#clientInfoEditForm #appSecret").addClass("layui-btn-disabled");
                            $("#clientInfoEditForm #agendId").addClass("layui-btn-disabled");
                            $("#clientInfoEditForm #clientHost").addClass("layui-btn-disabled");
                            $("#clientInfoEditForm #corpId").addClass("layui-btn-disabled");
                            $("#clientInfoEditForm #token").addClass("layui-btn-disabled");
                            $("#clientInfoEditForm #aesKey").addClass("layui-btn-disabled");
							$("#clientInfoFormBtn_div").hide();
							clientInfoClientTypeChangeShowHide(data.clientType)
							layui.form.render();
						}
					});
				}
				else if (layEvent === 'del') {
					layer.confirm('确认要删除吗？', function (index) {
						$.ajax({
							url: "/api/ClientInfo/Delete?id=" + data.id,
							type: "get",
							success: function (info) {
								if (info.code === 1) {
                                    layer.close(index);
									//刷新数据表格
									clientInfoTable.reload('clientinfoTable')
								} else {
									layer.msg(info.msg);
								}
                            },
                            error: function (e) {
                                logout(e);
                            }
						});
					});
				}
				else if (layEvent === 'edit') {
					//iframe层
					mainIndex = layer.open({
						type: 1,
						offset: 'r',
						anim: 'slideLeft', // 从右往左
						title: '编辑',
						shadeClose: true,
						shade: 0.1,
						area: ['30%', '100%'],//宽 高
						content: $("#addorupdateclientInfopage"),
						success: function () {
							var readForm = layui.$('[lay-filter="clientInfoEditForm"]')
                            readForm.find('input,textarea,select').prop('disabled', false);
                            $("#clientInfoEditForm #appId").removeClass("layui-btn-disabled");
                            $("#clientInfoEditForm #appSecret").removeClass("layui-btn-disabled");
                            $("#clientInfoEditForm #agendId").removeClass("layui-btn-disabled");
                            $("#clientInfoEditForm #clientHost").removeClass("layui-btn-disabled");
                            $("#clientInfoEditForm #corpId").removeClass("layui-btn-disabled");
                            $("#clientInfoEditForm #token").removeClass("layui-btn-disabled");
                            $("#clientInfoEditForm #aesKey").removeClass("layui-btn-disabled");
							$("#clientInfoFormBtn_div").show();
							form.val('clientInfoEditForm', data);
							clientInfoClientTypeChangeShowHide(data.clientType)
							layui.form.render();

						},
						cancel: function () {
							//清除下拉框值改变
							clearClientInfoClientTypeChange();
						}
					});
				}
			});

			//消息管理监听头工具栏事件
			table.on('toolbar(messageManageTableFilter)', function (obj) {
				var checkStatus = table.checkStatus(obj.config.id)
					, data = checkStatus.data; //获取选中的数据
				switch (obj.event) {
					case 'add':
						//iframe层
						mainIndex = layer.open({
							type: 1,
							offset: 'r',
							anim: 'slideLeft', // 从右往左
							title: '新增',
							shadeClose: true,
							area: ['40%', '100%'],//宽 高
							shade: 0.1,
							shadeClose: true,
							content: $("#addorupdatemessagepage"),
							success: function (index) {
								//清空数据表格
                                $('#messageEditForm')[0].reset();
								//执行清空
                                $("#messagepage_content").text('');
								//执行清空
								//$("#msgtype").empty();
								//$('#msgtype').append(new Option("直接选择或搜索选择", ''));// 下拉菜单里添加元素
								form.render("textarea");
                                var readForm = layui.$('[lay-filter="messageEditForm"]')
								readForm.find('input,textarea,select').prop('disabled', false);
                                $("#messageFormBtn_div").show();
								layui.form.render();
							}
						});
						break;
				};
			});

			//消息管理监听行工具事件
			table.on('tool(messageManageTableFilter)', function (obj) { //注：tool 是工具条事件名，test 是 table 原始容器的属性 lay-filter="对应的值"
				var data = obj.data //获得当前行数据
					, layEvent = obj.event; //获得 lay-event 对应的值
				if (layEvent === 'detail') {
					//iframe层
					layer.open({
						type: 1,
						offset: 'r',
						anim: 'slideLeft', // 从右往左
						title: '查看',
						shadeClose: true,
						shade: 0.1,
						area: ['40%', '100%'],//宽 高
						content: $("#addorupdatemessagepage"),
						success: function () {
							form.val('messageEditForm', data);
							var readForm = layui.$('[lay-filter="messageEditForm"]')
							readForm.find('input,textarea,select').prop('disabled', true);
							$("#messageFormBtn_div").hide();
							layui.form.render();
						}
					});
				}
				else if (layEvent === 'edit') {
					if (data.status === 2) {
						layer.msg('成功的消息不能重新发送');
						return;
					}
					//iframe层
					mainIndex = layer.open({
						type: 1,
						offset: 'r',
						anim: 'slideLeft', // 从右往左
						title: '重新发送',
						shadeClose: true,
						shade: 0.1,
						area: ['40%', '100%'],//宽 高
						content: $("#addorupdatemessagepage"),
                        success: function () {
							form.val('messageEditForm', data);
							var readForm = layui.$('[lay-filter="messageEditForm"]')
							readForm.find('input,textarea,select').prop('disabled', false);
							$("#messageFormBtn_div").show();
                            bidMsgType(data.source);
                            $("#msgtype").val(data.msgtype);
                            layui.form.render();
						}
					});
				}
			});

			//应用管理配置监听头工具栏事件
			table.on('toolbar(sourceTableFilter)', function (obj) {
				var checkStatus = table.checkStatus(obj.config.id)
					, data = checkStatus.data; //获取选中的数据
				switch (obj.event) {
					case 'add':
						//iframe层
						mainIndex = layer.open({
							type: 1,
							title: '新增',
							shadeClose: true,
							shade: 0.8,
							area: ['40%', '25%'],//宽 高
							content: $("#addorupdatesourcepage"),
							success: function (index) {
								//清空数据表格
								$('#sourceEditForm')[0].reset();
                                var readForm = layui.$('[lay-filter="sourceEditForm"]')
                                readForm.find('input,textarea,select').prop('disabled', false);
                                $("#sourceEditForm #code").removeClass("layui-btn-disabled");
                                $("#sourceEditForm #name").removeClass("layui-btn-disabled");
								$("#sourceFormBtn_div").show();
								layui.form.render();
							}
						});
						break;
					case 'batchDel':
						if (data.length === 0) {
							layer.msg('请选择一行');
						} else {
							var idArray = [];
							for (var i = 0; i < data.length; i++) {
								idArray.push(data[i].id);
							}
							layer.confirm('确认要删除吗？', function (index) {
								$.ajax({
									url: "/api/Source/BatchDelete?ids=" + idArray.join(','),
									type: "get",
									success: function (info) {
										if (info.code === 1) {
                                            layer.close(index);
											//刷新数据表格
											sourceTable.reload('sourceTable')
										} else {
											layer.msg(info.msg);
										}
                                    },
                                    error: function (e) {
                                        logout(e);
                                    }
								});
							});
						}
						break;
				};
			});

			//应用配置监听行工具事件
			table.on('tool(sourceTableFilter)', function (obj) { //注：tool 是工具条事件名，test 是 table 原始容器的属性 lay-filter="对应的值"
				var data = obj.data //获得当前行数据
					, layEvent = obj.event; //获得 lay-event 对应的值
				if (layEvent === 'detail') {
					//iframe层
					layer.open({
						type: 1,
						title: '查看',
						shadeClose: true,
						shade: 0.8,
						area: ['40%', '25%'],//宽 高
						content: $("#addorupdatesourcepage"),
						success: function () {
							form.val('sourceEditForm', data);
							var readForm = layui.$('[lay-filter="sourceEditForm"]')
                            readForm.find('input,textarea,select').prop('disabled', true);
                            $("#sourceEditForm #code").addClass("layui-btn-disabled");
                            $("#sourceEditForm #name").addClass("layui-btn-disabled");
							$("#sourceFormBtn_div").hide();
							layui.form.render();
						}
					});
				}
				else if (layEvent === 'del') {
					layer.confirm('确认要删除吗？', function (index) {
						$.ajax({
							url: "/api/Source/Delete?id=" + data.id,
							type: "get",
							success: function (info) {
								if (info.code === 1) {
                                    layer.close(index);
									//刷新数据表格
									sourceTable.reload('sourceTable')
								} else {
									layer.msg(info.msg);
								}
                            },
                            error: function (e) {
                                logout(e);
                            }
						});
					});
				}
				else if (layEvent === 'edit') {
					//iframe层
					mainIndex = layer.open({
						type: 1,
						title: '编辑',
						shadeClose: true,
						shade: 0.8,
						area: ['40%', '25%'],//宽 高
						content: $("#addorupdatesourcepage"),
						success: function () {
							form.val('sourceEditForm', data);
							var readForm = layui.$('[lay-filter="sourceEditForm"]')
							readForm.find('input,textarea,select').prop('disabled', false);
							$("#sourceEditForm #code").attr("disabled", true);
                            $("#sourceEditForm #code").addClass("layui-btn-disabled");
                            $("#sourceEditForm #name").removeClass("layui-btn-disabled");
							$("#sourceFormBtn_div").show();
							layui.form.render();

						}
					});
				}
			});


			//消息管理监听头工具栏事件
			table.on('toolbar(messageTypesTableFilter)', function (obj) {
				var checkStatus = table.checkStatus(obj.config.id)
					, data = checkStatus.data; //获取选中的数据
				switch (obj.event) {
					case 'add':
						//iframe层
						mainIndex = layer.open({
							type: 1,
							offset: 'r',
							anim: 'slideLeft', // 从右往左
							title: '新增',
							shadeClose: true,
							area: ['30%', '100%'],//宽 高
							shade: 0.1,
							content: $("#addorupdatemessagetypespage"),
							success: function (index) {
								//清空数据表格
								$('#messageTypesEditForm')[0].reset();
								var readForm = layui.$('[lay-filter="messageTypesEditForm"]')
								readForm.find('input,textarea,select').prop('disabled', false);
                                $("#messageTypesEditForm #messageTypes_code").removeClass("layui-btn-disabled");
                                $("#messageTypesEditForm #messageTypes_name").removeClass("layui-btn-disabled");
								$("#messageTypesFormBtn_div").show();
								layui.form.render();
							}
						});
						break;
					case 'batchDel':
						if (data.length === 0) {
							layer.msg('请选择一行');
						} else {
							var idArray = [];
							for (var i = 0; i < data.length; i++) {
								idArray.push(data[i].id);
							}
							layer.confirm('确认要删除吗？', function (index) {
								$.ajax({
									url: "/api/MessageTypes/BatchDelete?ids=" + idArray.join(','),
									type: "get",
									success: function (info) {
										if (info.code === 1) {
                                            layer.close(index);
											//刷新数据表格
											messageTypesTable.reload('messageTypesTable');
										} else {
											layer.msg(info.msg);
										}
                                    },
                                    error: function (e) {
                                        logout(e);
                                    }
								});
							});
						}
						break;
				};
			});

			//消息管理监听行工具事件
			table.on('tool(messageTypesTableFilter)', function (obj) { //注：tool 是工具条事件名，test 是 table 原始容器的属性 lay-filter="对应的值"
				var data = obj.data //获得当前行数据
					, layEvent = obj.event; //获得 lay-event 对应的值
				if (layEvent === 'detail') {
					//iframe层
					layer.open({
						type: 1,
						offset: 'r',
						anim: 'slideLeft', // 从右往左
						title: '查看',
						shadeClose: true,
						shade: 0.1,
						area: ['30%', '100%'],//宽 高
						content: $("#addorupdatemessagetypespage"),
						success: function () {
							form.val('messageTypesEditForm', data);
							var readForm = layui.$('[lay-filter="messageTypesEditForm"]')
                            readForm.find('input,textarea,select').prop('disabled', true);
                            $("#messageTypesEditForm #messageTypes_code").addClass("layui-btn-disabled");
                            $("#messageTypesEditForm #messageTypes_name").addClass("layui-btn-disabled");
							$("#messageTypesFormBtn_div").hide();
							layui.form.render();
						}
					});
				}
				else if (layEvent === 'del') {
					layer.confirm('确认要删除吗？', function (index) {
						$.ajax({
							url: "/api/MessageTypes/Delete?id=" + data.id,
							type: "get",
							success: function (info) {
								if (info.code === 1) {
									layer.close(index);
									//刷新数据表格
									messageTypesTable.reload('messageTypesTable');
								} else {
									layer.msg(info.msg);
								}
                            },
                            error: function (e) {
                                logout(e);
                            }
						});
					});
				}
				else if (layEvent === 'edit') {
					//iframe层
					mainIndex = layer.open({
						type: 1,
						offset: 'r',
						anim: 'slideLeft', // 从右往左
						title: '编辑',
						shadeClose: true,
						shade: 0.1,
						area: ['30%', '100%'],//宽 高
						content: $("#addorupdatemessagetypespage"),
						success: function () {
							form.val('messageTypesEditForm', data);
							var readForm = layui.$('[lay-filter="messageTypesEditForm"]')
							readForm.find('input,textarea,select').prop('disabled', false);
                            $("#messageTypesEditForm #messageTypes_code").attr("disabled", true);
                            $("#messageTypesEditForm #messageTypes_code").addClass("layui-btn-disabled");
                            $("#messageTypesEditForm #messageTypes_name").removeClass("layui-btn-disabled");
							$("#messageTypesFormBtn_div").show();

							layui.form.render();
						}
					});
				}
				else if (layEvent === 'template') {
					//iframe层
					mainIndex = layer.open({
						type: 1,
						title: '模板配置',
						shadeClose: true,
						shade: 0.8,
						area: ['40%', '50%'],//宽 高
						content: $("#addorupdateselecttemplatepage"),
						success: function () {
							form.val('messageSelectTemplateEditForm', data);
							var readForm = layui.$('[lay-filter="messageSelectTemplateEditForm"]')
							readForm.find('input,textarea,select').prop('disabled', false);
							$("#messageSelectFormBtn_div").show();

							layui.form.render();
						}
					});
				}
			});


			//消息管理监听头工具栏事件
			table.on('toolbar(messageTemplateTableFilter)', function (obj) {
				var checkStatus = table.checkStatus(obj.config.id)
					, data = checkStatus.data; //获取选中的数据
				switch (obj.event) {
					case 'add':
						//iframe层
						mainIndex = layer.open({
							type: 1,
							offset: 'r',
							anim: 'slideLeft', // 从右往左
							title: '新增',
							shadeClose: true,
							area: ['40%', '100%'],//宽 高
							shade: 0.1,
							content: $("#addorupdatemessagetemplatepage"),
							success: function (index) {
								//清空数据表格
								$('#messageTemplateEditForm')[0].reset();
								var readForm = layui.$('[lay-filter="messageTemplateEditForm"]')
                                readForm.find('input,textarea,select').prop('disabled', false);
                                $("#messageTemplateEditForm #messagetemplate_name").removeClass("layui-btn-disabled");
                                $("#messageTemplateEditForm #messagetemplate_content").removeClass("layui-btn-disabled");
                                $("#messageTemplateEditForm #messagetemplate_example").removeClass("layui-btn-disabled");
                                $("#messageTemplateEditForm #messagetemplate_sendJson").removeClass("layui-btn-disabled");
								$("#messageTemplateFormBtn_div").show();
								layui.form.render();
							}
						});
						break;
					case 'batchDel':
						if (data.length === 0) {
							layer.msg('请选择一行');
						} else {
							var idArray = [];
							for (var i = 0; i < data.length; i++) {
								idArray.push(data[i].id);
							}
							layer.confirm('确认要删除吗？', function (index) {
								$.ajax({
									url: "/api/MessageTmplates/BatchDelete?ids=" + idArray.join(','),
									type: "get",
									success: function (info) {
										if (info.code === 1) {
                                            layer.close(index);
											//刷新数据表格
                                            messageTemplateTable.reload('messageTypesTable');
										} else {
											layer.msg(info.msg);
										}
                                    },
                                    error: function (e) {
                                        logout(e);
                                    }
								});
							});
						}
						break;
				};
			});

			//消息管理监听行工具事件
			table.on('tool(messageTemplateTableFilter)', function (obj) { //注：tool 是工具条事件名，test 是 table 原始容器的属性 lay-filter="对应的值"
				var data = obj.data //获得当前行数据
					, layEvent = obj.event; //获得 lay-event 对应的值
				if (layEvent === 'detail') {
					//iframe层
					layer.open({
						type: 1,
						offset: 'r',
						anim: 'slideLeft', // 从右往左
						title: '查看',
						shadeClose: true,
						shade: 0.1,
						area: ['40%', '100%'],//宽 高
						content: $("#addorupdatemessagetemplatepage"),
						success: function () {
							form.val('messageTemplateEditForm', data);
							var readForm = layui.$('[lay-filter="messageTemplateEditForm"]')
                            readForm.find('input,textarea,select').prop('disabled', true);
                            $("#messageTemplateEditForm #messagetemplate_name").addClass("layui-btn-disabled");
                            $("#messageTemplateEditForm #messagetemplate_content").addClass("layui-btn-disabled");
                            $("#messageTemplateEditForm #messagetemplate_example").addClass("layui-btn-disabled");
							$("#messageTemplateEditForm #messagetemplate_sendJson").addClass("layui-btn-disabled");
							$("#messageTemplateFormBtn_div").hide();
							layui.form.render();
						}
					});
				}
				else if (layEvent === 'del') {
					layer.confirm('确认要删除吗？', function (index) {
						$.ajax({
                            url: "/api/MessageTmplates/Delete?id=" + data.id,
							type: "get",
							success: function (info) {
								if (info.code === 1) {
                                    layer.close(index);
									//刷新数据表格
                                    messageTemplateTable.reload('messageTemplateTable');
								} else {
									layer.msg(info.msg);
								}
                            },
                            error: function (e) {
                                logout(e);
                            }
						});
					});
				}
				else if (layEvent === 'edit') {
					//iframe层
					mainIndex = layer.open({
						type: 1,
						offset: 'r',
						anim: 'slideLeft', // 从右往左
						title: '编辑',
						shadeClose: true,
						shade: 0.1,
						area: ['40%', '100%'],//宽 高
						content: $("#addorupdatemessagetemplatepage"),
						success: function () {
							form.val('messageTemplateEditForm', data);
							var readForm = layui.$('[lay-filter="messageTemplateEditForm"]')
                            readForm.find('input,textarea,select').prop('disabled', false);
                            $("#messageTemplateEditForm #messagetemplate_name").removeClass("layui-btn-disabled");
                            $("#messageTemplateEditForm #messagetemplate_content").removeClass("layui-btn-disabled");
                            $("#messageTemplateEditForm #messagetemplate_example").removeClass("layui-btn-disabled");
                            $("#messageTemplateEditForm #messagetemplate_sendJson").removeClass("layui-btn-disabled");
							$("#messageTemplateFormBtn_div").show();

							layui.form.render();
						}
					});
				}
			});



			//监听导航点击
			element.on('nav(test)', function (elem) {
				var elemId = elem.context.id;
				//动态加载应用下拉框值
				bindSource();
				if (elemId == "a_clientinfo") {
					renderClientinfoTable();
					//动态加载消息类型下拉框值
					$.ajax({
						url: '/api/SystemInfo/GetList',
						dataType: 'json', //服务器返回json格式数据
						type: 'get', //HTTP请求类型
						success: function (data) {
							var list = data.data.filter(item => {
								return item.code == "sendTypes"
							})
							var arry = JSON.parse(list[0].value);
							arry = arry.filter(item => {
								return item.ischecked == 1
							})
							$.each(arry, function (index, value) {
								if (value.ischecked == 1) {
									var ele = $("#clientInfo_sendTypes option[value='" + value.value + "']");
									if (ele.length == 0) {
										$('#clientInfo_sendTypes').append(new Option(value.name, value.value));// 下拉菜单里添加元素
									}
								}
							});

                        },
                        error: function (e) {
                            logout(e);
                        }
					});
					//$("[lay-id='clientinfoTable']").css('display', 'table-row');
					$("#clientinfoTable").css('display', 'table-row');
					$("#settingpage").css('display', 'none');
					$("[lay-id='messageManageTable']").css('display', 'none');
                    $("#messageManageTable").css('display', 'none');
                    $("#searchDiv").css('display', 'none');
					$("[lay-id='sourceTable']").css('display', 'none');
					$("#sourceTable").css('display', 'none');
					$("[lay-id='messageTypesTable']").css('display', 'none');
					$("#messageTypesTable").css('display', 'none');
					$("[lay-id='messageTemplateTable']").css('display', 'none');
					$("#messageTemplateTable").css('display', 'none');
				}
				else if (elemId == "a_messageManage") {
					//执行清空
					$("#msgtype").empty();
					$('#msgtype').append(new Option("直接选择或搜索选择", ''));// 下拉菜单里添加元素
					bidMsgType(0);
                    renderMessageManageTable($("#search_clientInfo_source").val(), $("#search_msg_content").val());
					//$("[lay-id='messageManageTable']").css('display', 'table-row');
					$("#settingpage").css('display', 'none');
                    $("#messageManageTable").css('display', 'table-row');
                    $("#searchDiv").css('display', 'block');
					$("[lay-id='clientinfoTable']").css('display', 'none');
					$("#clientinfoTable").css('display', 'none');
					$("[lay-id='sourceTable']").css('display', 'none');
					$("#sourceTable").css('display', 'none');
					$("[lay-id='messageTypesTable']").css('display', 'none');
					$("#messageTypesTable").css('display', 'none');
					$("[lay-id='messageTemplateTable']").css('display', 'none');
					$("#messageTemplateTable").css('display', 'none');
				}
				else if (elemId == "a_source") {
					renderSourceTable();
					//$("[lay-id='messageManageTable']").css('display', 'table-row');
					$("#settingpage").css('display', 'none');
					$("#sourceTable").css('display', 'table-row');
					$("[lay-id='clientinfoTable']").css('display', 'none');
					$("#clientinfoTable").css('display', 'none');
					$("[lay-id='messageManageTable']").css('display', 'none');
                    $("#messageManageTable").css('display', 'none');
                    $("#searchDiv").css('display', 'none');
					$("[lay-id='messageTypesTable']").css('display', 'none');
					$("#messageTypesTable").css('display', 'none');
					$("[lay-id='messageTemplateTable']").css('display', 'none');
					$("#messageTemplateTable").css('display', 'none');
				}
				else if (elemId == "a_setting") {
					$("#settingpage").css('display', 'block');
					$("[lay-id='sourceTable']").css('display', 'none');
					$("#sourceTable").css('display', 'none');
					$("[lay-id='clientinfoTable']").css('display', 'none');
					$("#clientinfoTable").css('display', 'none');
					$("[lay-id='messageManageTable']").css('display', 'none');
                    $("#messageManageTable").css('display', 'none');
                    $("#searchDiv").css('display', 'none');
					$("[lay-id='messageTypesTable']").css('display', 'none');
					$("#messageTypesTable").css('display', 'none');
					$("[lay-id='messageTemplateTable']").css('display', 'none');
					$("#messageTemplateTable").css('display', 'none');

					//动态加载消息类型下拉框值
					$.ajax({
						url: '/api/SystemInfo/GetList',
						dataType: 'json', //服务器返回json格式数据
						type: 'get', //HTTP请求类型
						success: function (data) {
							$.each(data.data, function (index, value) {
								if (value.code == "retryCount") {
									$("#retryCount").val(value.value);
								}
								else if (value.code == "firstRetryIntervalTime") {
									$("#firstRetryIntervalTime").val(value.value);
								}
								else if (value.code == "retryTimeGrowth") {
									$("#retryTimeGrowth").val(value.value);
								}
								else if (value.code == "sendTypes") {
									var arry = JSON.parse(value.value);
									$.each(arry, function (index, value) {
										var checkedStr = "";
										if (value.ischecked == 1) {
											checkedStr = "checked";
										}
										var ele = $("#sendtypes input[id='" + value.code + "']");
										if (ele.length > 0) {
											if (checkedStr == "") {
												ele.attr("checked", false)
											}
											else {
												ele.attr("checked", checkedStr)
											}
										}
										else {
											$("#sendtypes").append(" <input type = 'checkbox' id = '" + value.code + "' title = '" + value.name + "' value = '" + value.value + "' " + checkedStr + " /> ");
										}

									});
								}
								else if (value.code == "msgTypes") {
									var arry = JSON.parse(value.value);
									$.each(arry, function (index, value) {
										var checkedStr = "";
										if (value.ischecked == 1) {
											checkedStr = "checked";
										}
										var ele = $("#msgtypes input[id='" + value.code + "']");
										if (ele.length > 0) {
											if (checkedStr == "") {
												ele.attr("checked", false)
											}
											else {
												ele.attr("checked", checkedStr)
											}
										}
										else {
											$("#msgtypes").append(" <input type = 'checkbox' id = '" + value.code + "' title = '" + value.name + "' value = '" + value.value + "' " + checkedStr + " /> ");
										}

									});
								}
							});

							layui.form.render("checkbox");

                        },
                        error: function (e) {
                            logout(e);
                        }
					});
				}
				else if (elemId == "a_messageType") {
					//执行清空
					$("#messageTypes_sendTypes").empty();
					$('#messageTypes_sendTypes').append(new Option("直接选择或搜索选择", ''));// 下拉菜单里添加元素

					//执行清空
					$("#messageTypes_msgTypes").empty();
					$('#messageTypes_msgTypes').append(new Option("直接选择或搜索选择", ''));// 下拉菜单里添加元素
					bidMsgTemplate();
					renderMessageTypeTable();
					//动态加载消息类型下拉框值
					$.ajax({
						url: '/api/SystemInfo/GetList',
						dataType: 'json', //服务器返回json格式数据
						type: 'get', //HTTP请求类型
						success: function (data) {
							var list = data.data.filter(item => {
								return item.code == "sendTypes"
							})
							var arry = JSON.parse(list[0].value);
							arry = arry.filter(item => {
								return item.ischecked == 1
							})
							$.each(arry, function (index, value) {
								if (value.ischecked == 1) {
									var ele = $("#messageTypes_sendTypes option[value='" + value.value + "']");
									if (ele.length == 0) {
										$('#messageTypes_sendTypes').append(new Option(value.name, value.value));// 下拉菜单里添加元素
									}
								}
							});

							var list = data.data.filter(item => {
								return item.code == "msgTypes"
							})
							var arry = JSON.parse(list[0].value);
							arry = arry.filter(item => {
								return item.ischecked == 1
							})
							$.each(arry, function (index, value) {
								if (value.ischecked == 1) {
									var ele = $("#messageTypes_msgTypes option[value='" + value.value + "']");
									if (ele.length == 0) {
										$('#messageTypes_msgTypes').append(new Option(value.name, value.value));// 下拉菜单里添加元素
									}
								}
							});

							layui.form.render("select");
                        },
                        error: function (e) {
                            logout(e);
                        }
					});
					$("#settingpage").css('display', 'none');
					$("#messageTypesTable").css('display', 'table-row');
					$("[lay-id='sourceTable']").css('display', 'none');
					$("#sourceTable").css('display', 'none');
					$("[lay-id='clientinfoTable']").css('display', 'none');
					$("#clientinfoTable").css('display', 'none');
					$("[lay-id='messageManageTable']").css('display', 'none');
                    $("#messageManageTable").css('display', 'none');
                    $("#searchDiv").css('display', 'none');
					$("[lay-id='messageTemplateTable']").css('display', 'none');
					$("#messageTemplateTable").css('display', 'none');
				} else if (elemId == "a_messageTemplateType") {
					//var layedit = layui.layedit;
					//layedit.build('content'); //建立编辑器
					bidMsgType(0);
					renderMessageTemplateTable();
					$("#messageTemplateTable").css('display', 'table-row');
					$("#settingpage").css('display', 'none');
					$("[lay-id='messageTypesTable']").css('display', 'none');
					$("#messageTypesTable").css('display', 'none');
					$("[lay-id='sourceTable']").css('display', 'none');
					$("#sourceTable").css('display', 'none');
					$("[lay-id='clientinfoTable']").css('display', 'none');
					$("#clientinfoTable").css('display', 'none');
					$("[lay-id='messageManageTable']").css('display', 'none');
                    $("#messageManageTable").css('display', 'none');
                    $("#searchDiv").css('display', 'none');
				}
			});

			//监听下拉框值改变事件
			clientInfoClientTypeChange();

			//监听根据条件查询数据----表单提交事件
			form.on("submit(clientInfoSubmit)", function (data) {
				if (data.field.id === '') {
					data.field.id = 0;
				}
				data.field.id = parseInt(data.field.id)
				data.field.clientType = parseInt(data.field.clientType)
				data.field.source = parseInt(data.field.source)
				$.ajax({
					url: data.form.action,
					type: data.form.method,
					data: JSON.stringify(data.field),
					contentType: "application/json",
					success: function (info) {
						if (info.code === 1) {
							layer.close(mainIndex);
							//刷新数据表格
							clientInfoTable.reload('clientinfoTable')
						} else {
							layer.msg(info.msg);
						}
                    },
                    error: function (e) {
                        logout(e);
                    }
				});
				//实现禁止刷新页面
				return false;
			});
			//监听根据条件查询数据----表单提交事件
			form.on("submit(messageSubmit)", function (data) {
				if (data.field.id === '') {
					data.field.id = 0;
				}
				data.field.id = parseInt(data.field.id)
				data.field.msgtype = parseInt(data.field.msgtype)
				$.ajax({
					url: data.form.action,
					type: data.form.method,
					contentType: "application/json",
					data: JSON.stringify(data.field),
					success: function (info) {
						if (info.code === 1) {
							layer.close(mainIndex);
							//刷新数据表格
							messageManageTable.reload('messageManageTable');
						} else {
							layer.msg(info.msg);
						}
                    },
                    error: function (e) {
                        logout(e);
                    }
				});
				//实现禁止刷新页面
				return false;
			});

			//监听根据条件查询数据----表单提交事件
			form.on("submit(sourceSubmit)", function (data) {
				if (data.field.id === '') {
					data.field.id = 0;
				}
				data.field.id = parseInt(data.field.id)
				$.ajax({
					url: data.form.action,
					type: data.form.method,
					contentType: "application/json",
					data: JSON.stringify(data.field),
					success: function (info) {
						if (info.code === 1) {
							layer.close(mainIndex);
							//刷新数据表格
							sourceTable.reload('sourceTable');
						} else {
							layer.msg(info.msg);
						}
                    },
                    error: function (e) {
                        logout(e);
                    }
				});
				//实现禁止刷新页面
				return false;
			});

			//监听根据条件查询数据----表单提交事件
			form.on("submit(settingSubmit)", function (data) {
				var array = [];
				var retryCount = $("#retryCount").val();
				if (!isInteger(retryCount)) {
					layer.msg("重发次数必须为大于等于0的正整数");
					return false;
				}
				var firstRetryIntervalTime = $("#firstRetryIntervalTime").val();
                if (!isInteger(firstRetryIntervalTime) || firstRetryIntervalTime == '0') {
                    layer.msg("初次重发时间间隔必须为大于0的正整数");
                    return false;
                }
                if (parseInt(firstRetryIntervalTime) > 60) {
                    layer.msg("初次重发时间间隔不能大于60");
                    return false;
                }
                var retryTimeGrowth = $("#retryTimeGrowth").val();
                if (!isInteger(retryTimeGrowth) || retryTimeGrowth == '0') {
                    layer.msg("重发时间间隔增长必须为大于0的正整数");
                    return false;
                }
                array.push({ id: 0, code: "retryCount", name: "重发次数", value: retryCount });
                array.push({ id: 0, code: "firstRetryIntervalTime", name: "初次重发时间间隔", value: firstRetryIntervalTime });
                array.push({ id: 0, code: "retryTimeGrowth", name: "重发时间间隔增长", value: retryTimeGrowth });
				var sendTypeArr = [];
				$("#sendtypes input[type=checkbox]").each(function () {
					if ($(this).is(":checked")) {
						sendTypeArr.push({ code: $(this).attr('id'), name: $(this).attr('title'), value: $(this).val(), ischecked: 1 });
					} else {
						sendTypeArr.push({ code: $(this).attr('id'), name: $(this).attr('title'), value: $(this).val(), ischecked: 0 });
					}
                })
                var nocheckedSendTypeArr = sendTypeArr.filter(x => x.ischecked == 1);
                if (nocheckedSendTypeArr.length == 0) {
                    layer.msg("发送方式至少选择1个");
                    return false;
                }
				array.push({ id: 0, code: "sendTypes", name: "发送方式", value: JSON.stringify(sendTypeArr) });
				var msgTypeArr = [];
				$("#msgtypes input[type=checkbox]").each(function () {
					if ($(this).is(":checked")) {
						msgTypeArr.push({ code: $(this).attr('id'), name: $(this).attr('title'), value: $(this).val(), ischecked: 1 });
					} else {
						msgTypeArr.push({ code: $(this).attr('id'), name: $(this).attr('title'), value: $(this).val(), ischecked: 0 });
					}
				})
				var nocheckedMsgTypeArr = msgTypeArr.filter(x => x.ischecked == 1);
                if (nocheckedMsgTypeArr.length == 0) {
                    layer.msg("消息类别至少选择1个");
                    return false;
                }
				array.push({ id: 0, code: "msgTypes", name: "消息类别", value: JSON.stringify(msgTypeArr) });

				$.ajax({
					url: data.form.action,
					type: data.form.method,
					contentType: "application/json",
					data: JSON.stringify(array),
					success: function (info) {
						if (info.code === 1) {
							layer.msg("提交成功");
						} else {
							layer.msg("提交失败");
						}
                    },
                    error: function (e) {
                        logout(e);
                    }
				});
				//实现禁止刷新页面
				return false;
			});

			//监听根据条件查询数据----表单提交事件
			form.on("submit(messageTypesSubmit)", function (data) {
				if (data.field.id === '') {
					data.field.id = 0;
				}
                data.field.id = parseInt(data.field.id);
                data.field.sendType = parseInt(data.field.sendType);
                data.field.source = parseInt(data.field.source);
                data.field.enable = 1;
				//if (data.field.enable == "on") {
				//	data.field.enable = 1;
				//} else {
				//	data.field.enable = 0;
				//}
				$.ajax({
					url: data.form.action,
					type: data.form.method,
					data: JSON.stringify(data.field),
					contentType: "application/json",
					success: function (info) {
						if (info.code === 1) {
							layer.close(mainIndex);
							//刷新数据表格
							messageTypesTable.reload('messageTypesTable');
						} else {
							layer.msg(info.msg);
						}
                    },
                    error: function (e) {
                        logout(e);
                    }
				});
				//实现禁止刷新页面
				return false;
			});

			//监听根据条件查询数据----表单提交事件
			form.on("submit(messageTemplateSubmit)", function (data) {
				if (data.field.id === '') {
					data.field.id = 0;
				}
				data.field.id = parseInt(data.field.id);
                data.field.enable = 1;
				//if (data.field.enable == "on") {
				//	data.field.enable = 1;
				//} else {
				//	data.field.enable = 0;
				//}
				$.ajax({
					url: data.form.action,
					type: data.form.method,
					data: JSON.stringify(data.field),
					contentType: "application/json",
					success: function (info) {
						if (info.code === 1) {
							layer.close(mainIndex);
							//刷新数据表格
							messageTemplateTable.reload('messageTemplateTable');
						} else {
							layer.msg(info.msg);
						}
                    },
                    error: function (e) {
                        logout(e);
                    }
				});
				//实现禁止刷新页面
				return false;
			});

			//监听根据条件查询数据----表单提交事件
			form.on("submit(messageSelectTemplateSubmit)", function (data) {
				if (data.field.id === '') {
					data.field.id = 0;
				}
				data.field.id = parseInt(data.field.id)
				data.field.messageTemplateId = parseInt(data.field.messageTemplateId)

				$.ajax({
					url: data.form.action,
					type: data.form.method,
					data: JSON.stringify(data.field),
					contentType: "application/json",
					success: function (info) {
						if (info.code === 1) {
							layer.close(mainIndex);
							//刷新数据表格
							messageTypesTable.reload('messageTypesTable');
						} else {
							layer.msg(info.msg);
						}
                    },
                    error: function (e) {
                        logout(e);
                    }
				});
				//实现禁止刷新页面
				return false;
			});

			// select 事件
			form.on('select(message_source-select-filter)', function (data) {
				//执行清空
				$("#msgtype").empty();
				$('#msgtype').append(new Option("直接选择或搜索选择", ''));// 下拉菜单里添加元素
				form.render("select");
				//var elem = data.elem; // 获得 select 原始 DOM 对象
				var value = data.value; // 获得被选中的值
				//var othis = data.othis; // 获得 select 元素被替换后的 jQuery 对象

				//layer.msg(this.innerHTML + ' 的 value: ' + value); // this 为当前选中 <option> 元素对象
				bidMsgType(value);
			});
			// select 事件
			form.on('select(msgtype-select-filter)', function (data) {
				//执行清空
				$("#messagepage_content").text('');
				form.render("textarea");

				var value = data.value; // 获得被选中的值
				$.ajax({
                    url: '/api/MessageTypes/GetDetailById?id=' + value,
					dataType: 'json', //服务器返回json格式数据
					type: 'get', //HTTP请求类型
					success: function (data) {
						if (data.data != null) {
							$.each(data.data, function (index, value) {
								$('#messagepage_content').val(data.data.sendJson);
							});

							layui.form.render("textarea");
						}
                    },
                    error: function (e) {
                        logout(e);
                    }
				});
			});

            table.on('sort(messageManageTableFilter)', function (obj) {
                table.reload('messageManageTable', {//table对应的id
					initSort: obj,
					where: {
						field: obj.field,//排序字段
						order: obj.type//排序方式
					}
				})
            });
            table.on('sort(clientinfoTableFilter)', function (obj) {
                table.reload('clientinfoTable', {//table对应的id
                    initSort: obj,
                    where: {
                        field: obj.field,//排序字段
                        order: obj.type//排序方式
                    }
                })
            });
            table.on('sort(sourceTableFilter)', function (obj) {
                table.reload('sourceTable', {//table对应的id
                    initSort: obj,
                    where: {
                        field: obj.field,//排序字段
                        order: obj.type//排序方式
                    }
                })
            });
            table.on('sort(messageTypesTableFilter)', function (obj) {
                table.reload('messageTypesTable', {//table对应的id
                    initSort: obj,
                    where: {
                        field: obj.field,//排序字段
                        order: obj.type//排序方式
                    }
                })
            });
            table.on('sort(messageTemplateTableFilter)', function (obj) {
                table.reload('messageTemplateTable', {//table对应的id
                    initSort: obj,
                    where: {
                        field: obj.field,//排序字段
                        order: obj.type//排序方式
                    }
                })
			});
            //自定义验证规则
            form.verify({
                maxlength1: function (value) {
                    if (value.length > 1) {
                        return '输入长度1限制';
                    }
                },
                maxlength50: function (value) {
                    if (value.length > 50) {
                        return '输入长度50限制';
                    }
				},
				maxlength100: function (value) {
                    if (value.length > 100) {
                        return '输入长度100限制';
                    }
				},
				maxlength128: function (value) {
                    if (value.length > 128) {
                        return '输入长度128限制';
                    }
                },
                maxlength2000: function (value) {
                    if (value.length > 2000) {
                        return '输入长度2000限制';
                    }
                }
            });
		});
	</script>
</body>
</html>